/**
 * Created in 2012-2-28.
 */
package com.surekam.mnai.model;

import java.io.Serializable;

/**
 * 归属地址信息类型。
 * 
 * @author 吴政
 * 
 */
public class Address implements Serializable {

	/**
	 * 表示未知归属地址信息的常量。该常量的所有字段的set方法无效。
	 */
	public static final Address UNKNOW = new Address(0, "未知", "未知", "", "") {

		private static final long serialVersionUID = 1L;
		
		@Override
		public void setAddressId(Integer addressId) {}

		@Override
		public void setProvince(String province) {}

		@Override
		public void setCity(String city) {}

		@Override
		public void setAreaCode(String areaCode) {}

		@Override
		public void setPostCode(String postCode) {}
		
	};

	private static final long serialVersionUID = 1L;

	private Integer addressId;

	/**
	 * 所属省份。
	 */
	private String province;

	/**
	 * 所属城市。
	 */
	private String city;

	/**
	 * 区号。
	 */
	private String areaCode;

	/**
	 * 邮政编码。
	 */
	private String postCode;

	public Address() {
		;
	}

	public Address(Integer addressId, String province, String city,
			String areaCode, String postCode) {
		this.addressId = addressId;
		this.province = province;
		this.city = city;
		this.areaCode = areaCode;
		this.postCode = postCode;
	}

	public Integer getAddressId() {
		return addressId;
	}

	public void setAddressId(Integer addressId) {
		this.addressId = addressId;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public String getPostCode() {
		return postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	@Override
	public int hashCode() {
		int code = 17;

		code = code * 17 + addressId;
		code = code * 17 + province.hashCode();
		code = code * 17 + city.hashCode();
		code = code * 17 + areaCode.hashCode();
		code = code * 17 + postCode.hashCode();

		return code;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (obj instanceof Address) {
			Address other = (Address) obj;

			if (this.addressId.equals(other.addressId)
					&& this.province.equals(other.province)) {
				return true;
			}
		}

		return false;
	}

}
